home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PC World Komputer 2010 April
/
PCWorld0410.iso
/
pluginy Firefox
/
398
/
398.xpi
/
chrome
/
forecastfox.jar
/
content
/
icons
/
web-service.js
< prev
Wrap
Text File
|
2010-02-04
|
4KB
|
105 lines
/*------------------------------------------------------------------------------
Copyright (c) 2008 Ensolis, LLC. All Rights Reserved.
----------------------------------------------------------------------------*/
/******************************************************************************
* Performs a security check on a url.
*
* @param URL to check.
* @param Parent window for error alert.
* @return True if security check passes.
*****************************************************************************/
function securityCheck(aURL, aParent)
{
if (! (/^https?:\/\/.+\.jar$/i).test(aURL)) {
Components.utils.reportError("Invalid argument passed to window.forecastfox.installIconPack: Unsupported pack URL." );
//get stringbundle
var bundle = getBundle();
//Show error message
var title = bundle.GetStringFromName("ff.web.check.name");
var message = bundle.GetStringFromName("ff.web.check.url.message");
getPrompter(aParent).alert(title, message);
return false;
}
return true;
}
/******************************************************************************
* Interfaces that is a global window property. Used for
* getting Forecastfox information and installing icons.
*
* @status FROZEN
* @version 1.0
******************************************************************************/
function WebService() {}
////////////////////////////////
// nsISupports
WebService.prototype.QueryInterface = function WebService_QueryInterface(aIID)
{
var ifaces = this.getInterfaces({});
for (var i=0; i<ifaces.length; i++) {
if (aIID.equals(ifaces[i]))
return this;
}
throw Cr.NS_ERROR_NO_INTERFACE;
};
////////////////////////////////
// nsIClassInfo
WebService.prototype.getInterfaces = function WebService_getInterfaces(aCount)
{
var ifaces = [Ci.ffIWebService, Ci.nsIClassInfo, Ci.nsISupports];
aCount.value = ifaces.length;
return ifaces;
};
WebService.prototype.getHelperForLanguage = function WebService_getHelperForLanguage(aLanguage) { return null; };
WebService.prototype.contractID = gComponents["WebService"].contractID;
WebService.prototype.classID = gComponents["WebService"].classID;
WebService.prototype.classDescription = gComponents["WebService"].className;
WebService.prototype.implementationLanguage = Ci.nsIProgrammingLanguage.JAVASCRIPT;
WebService.prototype.flags = Ci.nsIClassInfo.DOM_OBJECT;
////////////////////////////////
// ffIWebService
/**
* String version of Forecastfox
*/
WebService.prototype.version = "0.9.10";
/**
* Installs an icon pack
*
* @param Name of the pack to install.
* @param URL pack is installed from.
*/
WebService.prototype.installIconPack = function WebService_installIconPack(aName, aURL)
{
//get topmost window
var win = getTopWindow();
//check url for security
if (!securityCheck(aURL, win))
return;
//get the window watcher service
var watcher = Cc["@mozilla.org/embedcomp/window-watcher;1"].
getService(Ci.nsIWindowWatcher);
//create dialog parameters
var params = Cc["@mozilla.org/embedcomp/dialogparam;1"].
createInstance(Ci.nsIDialogParamBlock);
params.SetString(0, aName);
params.SetString(1, aURL);
//open install dialog
watcher.openWindow(win, "chrome://forecastfox/content/icons/icons.xul",
"_blank", "chrome,centerscreen,modal,dialog,titlebar",
params);
};